<?php

/**
 * Helper_Auth
 *
 * @category    Ext
 * @package     Ext_Controller
 * @subpackage  Ext_Controller_Action_Helper
 */
class Ext_Controller_Action_Helper_Auth extends Zend_Controller_Action_Helper_Abstract
{
    /**
     * Current user instance
     *
     * @var Model_Member
     */
    protected $_currentMember = null;

    /**
     * Checking if user logged in
     *
     * @return bool
     */
    public function isLoggedIn()
    {
        return Zend_Auth::getInstance()->hasIdentity();
    }

    /**
     * Return current user instance
     *
     * @return int|null
     */
    public function getCurrentMember()
    {
        if ($this->isLoggedIn()) {
            if (!$this->_currentMember) {
                $this->_currentMember = Zend_Auth::getInstance()->getIdentity();
            }
        }
        return $this->_currentMember;
    }
}